//
//  Note.m
//  TigerClef
//
//  Created by Christopher Laguna on 6/29/13.
//  Copyright (c) 2013 Christopher Laguna. All rights reserved.
//

#import "Note.h"
#import "StaffView.h"

@implementation Note {
    
}

@synthesize imageView;
@synthesize xOffsetsFromCenter;
@synthesize yOffsetsFromCenter;
@synthesize yOffsetFromCenter;
@synthesize xOffsetFromCenter;
@synthesize orientation;
@synthesize ledgerlines;

- (id) init: (int) type {
    self = [super init];

    ledgerlines = [[NSMutableArray alloc] init];
    
    switch (type) {
        case kQuarter: {
            imageView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"QuarterNoteImg.png"]];
            imageView.frame = CGRectMake(0,0,75,75);
            xOffsetFromCenter = 0.f;
            yOffsetFromCenter = 25.5f;
            xOffsetsFromCenter = [NSMutableArray arrayWithObjects:[NSNumber numberWithFloat:0.f], [NSNumber numberWithFloat:0.f], nil];
            yOffsetsFromCenter = [NSMutableArray arrayWithObjects:[NSNumber numberWithFloat:25.5f], [NSNumber numberWithFloat:-26.f], nil];
            orientation = stemUp;
        }
    }
    return self;
}

- (void) putCenterAt: (CGPoint) newCenter {
    self.imageView.center = CGPointMake(newCenter.x - xOffsetFromCenter, newCenter.y - yOffsetFromCenter);
}

- (void) makeOriented: (int) orientationp {
    if (orientation != orientationp) {
        imageView.transform = CGAffineTransformRotate(self.imageView.transform, M_PI);

    }
    
    orientation = orientationp;
    xOffsetFromCenter = [[xOffsetsFromCenter objectAtIndex:orientationp] floatValue];
    yOffsetFromCenter = [[yOffsetsFromCenter objectAtIndex:orientationp] floatValue];
}


@end
